package com.xianbeiying.app.ckgl.widght;

/**
 * Created by Adminis on 2016/8/22.
 */

import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.provider.Settings;

/**
 * 自定义DiaLog
 * 用于权限判断 跳转应用设置界面
 * Created by Administrator on 2016/5/31.
 */
public class CustomDilog {

    public static void dialog(final Context context, final Activity activity) {

        AlertDialog.Builder builder = new AlertDialog.Builder(context);
        builder.setMessage("这些权限是应用运行所必须的，请去设置里手动添加");

        builder.setTitle("提示");

        builder.setPositiveButton("去设置", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                Uri packageURI = Uri.parse("package:" + "travel.xianbeiying.com.travel");
                Intent intent =  new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS,packageURI);
                context.startActivity(intent);
                dialog.dismiss();
                activity.finish();

            }
        });

        builder.setNegativeButton("取消", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                dialog.dismiss();
                activity.finish();
            }
        });

        builder.create().show();
    }
}
